package org.redr.widgetGUI.core;

import org.redr.widgetGUI.settings.WidgetSettings;
import org.redr.widgetGUI.settings.WidgetState;

import com.trolltech.qt.gui.QGroupBox;
import com.trolltech.qt.gui.QLayout;
import com.trolltech.qt.gui.QVBoxLayout;
import com.trolltech.qt.gui.QWidget;

public class GroupBox extends LayoutState{
	
	QGroupBox groupBox;
	
	public void addWidget(WidgetState ws){
		System.out.println("Adding widget to the layout");
		addWidget(ws.getWidgetBox());
	}
	
	public void addWidget(QWidget w){
		w.setParent(widgetBox);
		groupBox.layout().addWidget(w);
	}
	
	public GroupBox(LayoutState s, WidgetSettings ws){
		super(s, ws);
		groupBox = new QGroupBox();
		groupBox.setLayout(new QVBoxLayout());
		groupBox.setTitle(_getSetting("label", "!!FIX ME label SHOULD BE SET!!"));
		s.addWidget(groupBox);
	}
	
	public GroupBox(QLayout layout, WidgetSettings ws){
		super(ws);
		groupBox = new QGroupBox();
		groupBox.setLayout(new QVBoxLayout());
		groupBox.setTitle(_getSetting("label", "!!FIX ME label SHOULD BE SET!!"));
		layout.addWidget(groupBox);
	}

	public QWidget widget() {
		// TODO Auto-generated method stub
		return groupBox;
	}

	@Override
	public void removeWidget(WidgetState ws) {
		// TODO Auto-generated method stub
		removeWidget(ws.getWidgetBox());
	}

	@Override
	public void removeWidget(QWidget w) {
		// TODO Auto-generated method stub
		groupBox.layout().removeWidget(w);
	}
	
}
